//
//  UIViewController+subReload.m
//  p2p
//
//  Created by LiuHe@MacMini on 14-8-5.
//  Copyright (c) 2014年 cloudyoo. All rights reserved.
//

#import "UIViewController+zframework.h"
#import "JRSwizzle.h"
@implementation UIViewController (zframework)


//黑魔法 
+(void)load{
    [super load];
    NSError *error = nil;
    [self jr_swizzleMethod:@selector(viewWillAppear:) withMethod:@selector(xxx_viewWillAppear:) error:&error];
   
    if (error) {
        debugLog(@"swizzle viewDidAppear fail");
    }else{
        [self jr_swizzleMethod:@selector(viewWillDisappear:) withMethod:@selector(xxx_viewWillDisappear:) error:&error];
        if (error) {
             debugLog(@"swizzle viewDidDisappear fail");
        }
    }
}

-(void)xxx_viewWillAppear:(BOOL)animated{
    [self xxx_viewWillAppear:animated];
     NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(appWillEnterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
    [center addObserver:self selector:@selector(appDidEnterBackgroundNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

-(void)xxx_viewWillDisappear:(BOOL)animated{
    [self xxx_viewWillDisappear:animated];
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
    [center removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
}

-(void)appDidEnterBackgroundNotification{
}
-(void)appWillEnterForegroundNotification{
}


@end
